package pl.edu.pw.stud.ltrzaska.report;

import java.util.List;

import pl.edu.pw.stud.ltrzaska.logic.PolicyViolation;

public class TxtReportFormatter implements IReportFormatter {

	@Override
	public String format(List<PolicyViolation> violations) {
		StringBuffer result = new StringBuffer();
		for(PolicyViolation pv : violations) {
			result.append("#------------------------------------------");
			result.append("\n");
			result.append("Nazwa: " + pv.getName());
			result.append("\n");
			if(pv.getShortDescription() != null) {
				result.append("Opis: " + pv.getShortDescription());
				result.append("\n");
			}
			if(pv.getDetailedDescription() != null) {
				result.append("Pelny opis: " + pv.getDetailedDescription());
				result.append("\n");
			}
			if(pv.getPolicyFileObject() != null) {
				result.append("Obiekt polityki (" + pv.getPolicyFileObject().getClass().getName() + "): " + pv.getPolicyFileObject().getName());
				result.append("\n");
			}
			if(pv.getVirtualFileObject() != null) {
				result.append("Obiekt w systemie plikow: " + pv.getVirtualFileObject().getName());
				result.append("\n");
			}
			if(pv.getValidatorClazz() != null) {
				result.append("Zglosil walidator: " + pv.getPolicyFileObject().getName());
				result.append("\n");
			}
		}
		result.append("Lacznie wykryto niezgodnosci: " + violations.size());
		return result.toString();
	}	
}
